

    const md5 = require('md5')
    const uuid = require('uuid')
    const jwt = require('jsonwebtoken')
    const baseConfig = require('../config/base-config')

    module.exports = {
        // 生产token
        getUserToken: (payload) => {
            let nowDate = new Date()
            payload.iat = nowDate.getTime()
            const token = jwt.sign(payload, baseConfig.jwt.serectKey, { expiresIn: baseConfig.jwt.tokenExpiresTime })
            return token
        },

        // 获取uuid
        generateId: () => {
            return uuid.v4
        },

        // 使用盐值md5加密
        getMd5Pass: async (val) => {
            let passSalt = md5(md5(val))
            return passSalt
        }
    }